package com.cuitrip.business.share.ui;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.cuitrip.business.share.ShareChannelBuilder;
import com.cuitrip.business.share.model.Share;
import com.cuitrip.business.tripservice.ui.IconTextView;
import com.cuitrip.service.R;
import com.cuitrip.util.ResourceUtil;

import butterknife.ButterKnife;
import butterknife.Bind;
import cn.sharesdk.facebook.Facebook;
import cn.sharesdk.onekeyshare.OnekeyShare;
import cn.sharesdk.sina.weibo.SinaWeibo;
import cn.sharesdk.system.email.Email;
import cn.sharesdk.tencent.qq.QQ;
import cn.sharesdk.tencent.qzone.QZone;
import cn.sharesdk.twitter.Twitter;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;

/**
 * Created by ak on 15/11/24.
 */
public class ShareItemView extends RecyclerView.ViewHolder {

    @Bind(R.id.share_item_logo)
    IconTextView itemLogo;
    @Bind(R.id.share_item_text)
    TextView itemText;
    @Bind(R.id.item_layout)
    View itemLayout;
    @Bind(R.id.section_line)
    View sectionLine;

    public ShareItemView(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);
    }

    public void render(final Object object) {
        if (object instanceof ShareChannelBuilder.TripShareChannel){
            ShareChannelBuilder.TripShareChannel share = (ShareChannelBuilder.TripShareChannel) object;
            if (ShareChannelBuilder.TripShareChannel.WECHAT.ordinal() == share.ordinal()) {
                itemText.setText(R.string.ssdk_wechat);
                itemLogo.setText(R.string.wechat_icon);
                itemLayout.setBackgroundResource(R.drawable.shape_rect_apple_soild_4dp);
                sectionLine.setVisibility(View.VISIBLE);
            }else if (ShareChannelBuilder.TripShareChannel.MOMMENTS.ordinal() == share.ordinal()){
                itemText.setText(R.string.ssdk_wechatmoments);
                itemLogo.setText(R.string.momments_icon);
                itemLayout.setBackgroundResource(R.drawable.shape_rect_apple_soild_4dp);
                sectionLine.setVisibility(View.VISIBLE);
            }else if (ShareChannelBuilder.TripShareChannel.WEIBO.ordinal() == share.ordinal()){
                itemText.setText(R.string.ssdk_sinaweibo);
                itemLogo.setText(R.string.weibo_icon);
                itemLayout.setBackgroundResource(R.drawable.shape_rect_red_soild_4dp);
                sectionLine.setVisibility(View.VISIBLE);
            }
            else if (ShareChannelBuilder.TripShareChannel.QQ.ordinal() == share.ordinal()){
                itemText.setText(R.string.ssdk_qq);
                itemLogo.setText(R.string.qq_icon);
                itemLayout.setBackgroundResource(R.drawable.shape_rect_light_blue_soild_4dp);
                sectionLine.setVisibility(View.VISIBLE);
            }
            else if (ShareChannelBuilder.TripShareChannel.QQZONE.ordinal() == share.ordinal()){
                itemText.setText(R.string.ssdk_qzone);
                itemLogo.setText(R.string.qzone_icon);
                itemLayout.setBackgroundResource(R.drawable.shape_rect_mango_soild_4dp);
                sectionLine.setVisibility(View.VISIBLE);
            }
            else if (ShareChannelBuilder.TripShareChannel.MAIL.ordinal() == share.ordinal()){
                itemText.setText(R.string.ssdk_email);
                itemLayout.setBackgroundResource(R.drawable.shape_white_corner_transparent_soild_4dp);
                sectionLine.setVisibility(View.INVISIBLE);
            }
            else if (ShareChannelBuilder.TripShareChannel.FACEBOOK.ordinal() == share.ordinal()){
                itemText.setText(R.string.ssdk_facebook);
                itemLogo.setText(R.string.facebook_icon);
                itemLayout.setBackgroundResource(R.drawable.shape_rect_facebook_blue_soild_4dp);
                sectionLine.setVisibility(View.VISIBLE);
            }
            else if (ShareChannelBuilder.TripShareChannel.TWITTER.ordinal() == share.ordinal()){

            }else if (ShareChannelBuilder.TripShareChannel.COPY.ordinal() == share.ordinal()){
                itemText.setText(R.string.share_copy);
                sectionLine.setVisibility(View.INVISIBLE);
            }else if (ShareChannelBuilder.TripShareChannel.TITLE.ordinal() == share.ordinal()){
                itemText.setText(ResourceUtil.getString(R.string.share));
                sectionLine.setVisibility(View.INVISIBLE);
                itemLayout.setBackgroundResource(R.color.transparent);
            }else if (ShareChannelBuilder.TripShareChannel.More.ordinal() == share.ordinal()){
                itemText.setText(ResourceUtil.getString(R.string.operation_more));
                sectionLine.setVisibility(View.INVISIBLE);
            }
        }

    }



}

